﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MetaTracker.ViewModel;

namespace MetaTracker.View
{
    /// <summary>
    /// Interaction logic for RegisterWithingsView.xaml
    /// </summary>
    public partial class RegisterWithingsView : Window
    {
        public RegisterWithingsView()
        {
            InitializeComponent();
            
            if (DataContext == null || !(DataContext is RegisterWithingsViewModel))
            {
                var context = new RegisterWithingsViewModel();

                context.RequestClose +=new EventHandler<GUILib.DialogResultsEventArgs>((sender, args) => this.Close());

                DataContext = context;
            }

            
            //PasswordBox1.PasswordChanged += new RoutedEventHandler(PasswordBox1_PasswordChanged);
            //RegisterButton.Click += new RoutedEventHandler(RegisterButton_Click);
            //CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
        }

        //void CancelButton_Click(object sender, RoutedEventArgs e)
        //{
        //    this.Close();
        //}

        //void RegisterButton_Click(object sender, RoutedEventArgs e)
        //{
        //    bool success = (DataContext as RegisterWithingsViewModel).Register();
        //    if (!success)
        //    {
        //        MessageBox.Show("No Withings account found with the given email and password",
        //            "Bad Email or Password", MessageBoxButton.OK);
        //        return;
        //    }
        //    else
        //    {
        //        MessageBox.Show("Success!");
        //        this.Close();
        //    }


        //}

        //void PasswordBox1_PasswordChanged(object sender, RoutedEventArgs e)
        //{
        //    (DataContext as RegisterWithingsViewModel).WithingsPassword = PasswordBox1.SecurePassword;
        //}

        private void RegisterWithingsView_Loaded(object sender, RoutedEventArgs e)
        {
            Keyboard.Focus(this.UserIDTextBox);
        }
    }
}
